// components/index.js
import QCodePrism from 'components/Global/Tools/QCodePrism'

const componentsContext = import.meta.glob('./Global/**/*.vue', { eager: true })

const components = []

const loadComponents = app => {
  Object.keys(componentsContext).forEach(component => {
    const componentConfig = componentsContext[component]
    /**
     * 兼容 import export 和 require module.export 两种规范
     */
    const ctrl = componentConfig.default || componentConfig

    const name = ctrl.name || ctrl.__name
    app.component(name, ctrl)

    components.push(ctrl)
  })
  app.component(QCodePrism.name, QCodePrism)
}

export default loadComponents